/******************************************************************************
@file:  TransportTabHome.java
@author Ramesh Anandhan

DESCRIPTION
-----------------------------------------------------------------------------
Copyright (c) 2011, GEEKWAVE SOLUTIONS INC.

All rights reserved.
 ******************************************************************************/
package com.smartc.ui;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.TabHost;

public class TransportTabHome extends TabActivity implements
		TabHost.OnTabChangeListener {

	// private final int TAB_HOME = 0;
	// private final int TAB_BUS_REGISTER = 1;
	// private final int TAB_CAB_REQUEST= 2;
	// private final int TAB_SEARCH = 3;
	// private final int TAB_FEEDBACK = 4;

	private static final String TAG = null;
	private TabHost mTabHost;

	public static boolean mTabChanged = false;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.transport_tab_home);
		mTabHost = getTabHost();
		mTabHost.setOnTabChangedListener(this);

		setHomeTab();
		setBusRegisterTab();
		setCabRequestTab();
		setSearchTab();
		setFeedbackTab();
	}

	private void setHomeTab() {
		Intent intent = new Intent();
		intent.setClass(this, TransportHomeActivity.class);
		// StickyTabs.setTab(intent, TAB_BUS_REGISTER);

		mTabHost.addTab(mTabHost.newTabSpec("transport_home").setIndicator(
				"Home", getResources().getDrawable(R.drawable.home1))
				.setContent(intent));
	}

	private void setBusRegisterTab() {
		Intent intent = new Intent();
		intent.setClass(this, BusRegister.class);
		// StickyTabs.setTab(intent, TAB_BUS_REGISTER);

		mTabHost.addTab(mTabHost.newTabSpec("bus_register").setIndicator(
				getString(R.string.transport_busregister),
				getResources().getDrawable(R.drawable.transportation_bus_32))
				.setContent(intent));
	}

	private void setCabRequestTab() {
		Intent intent = new Intent();
		intent.setClass(this, CabRequest.class);
		// StickyTabs.setTab(intent, TAB_BUS_REGISTER);

		mTabHost.addTab(mTabHost.newTabSpec("cab_request").setIndicator(
				getString(R.string.cab_request),
				getResources().getDrawable(R.drawable.car)).setContent(intent));
	}

	private void setSearchTab() {
		Intent intent = new Intent();
		intent.setClass(this, SearchHome.class);
		// StickyTabs.setTab(intent, TAB_BUS_REGISTER);

		mTabHost.addTab(mTabHost.newTabSpec("search").setIndicator(
				getString(R.string.search),
				getResources().getDrawable(R.drawable.toolbar_find))
				.setContent(intent));
	}

	private void setFeedbackTab() {
		Intent intent = new Intent();
		intent.setClass(this, Feedback.class);
		// StickyTabs.setTab(intent, TAB_BUS_REGISTER);

		mTabHost.addTab(mTabHost.newTabSpec("feedback").setIndicator(
				getString(R.string.feedback),
				getResources().getDrawable(R.drawable.feedback)).setContent(
				intent));
	}

	@Override
	public void onTabChanged(String tabId) {
		if (AccountLogin.DEBUG)
			Log.i(TAG, "onTabChanged() tabId:" + tabId);
		Activity activity = getLocalActivityManager().getActivity(tabId);
		if (activity != null) {
			mTabChanged = true;
			activity.onWindowFocusChanged(true);
		} else {
			if (AccountLogin.DEBUG)
				Log.i(TAG, "onTabChanged() activity == nul");
		}
	}
}
